import { Controller, HttpStatus, Post, Query } from '@nestjs/common';
import { CommonService } from './common.service';
import {
  ApiBearerAuth,
  ApiOperation,
  ApiQuery,
  ApiResponse,
  ApiTags,
} from '@nestjs/swagger';
import { PublicVoError, PublicVoSuccess } from 'src/utils/publicVo';
import { RequireLogin } from 'src/middleware/auth/custom.decorator';

@ApiTags('公共模块')
@Controller('common')
export class CommonController {
  constructor(private readonly commonService: CommonService) {}
  @Post('upload')
  @ApiBearerAuth()
  @RequireLogin()
  @ApiOperation({ summary: '图片上传', description: '图片上传签名接口' })
  @ApiResponse({
    status: HttpStatus.OK,
    description: '请求成功',
    type: PublicVoSuccess,
  })
  @ApiResponse({
    status: HttpStatus.BAD_REQUEST,
    description: '请求失败',
    type: PublicVoError,
  })
  @ApiQuery({
    name: 'name',
    type: String,
    description: '图片名',
    required: true,
  })
  async upload(@Query('name') name: string) {
    return await this.commonService.upload(name);
  }
}
